package com.chancingpack.service.impl;

import com.chancingpack.bean.WxReceiveMessageBean;
import com.chancingpack.dal.dao.WxReceiveMessageDao;
import com.chancingpack.dal.model.WxReceiveMessage;
import com.chancingpack.service.WxReceiveMessageService;
import com.chancingpack.service.WxSendMessageService;
import com.chancingpack.util.CommonResult;
import com.chancingpack.util.ObjectUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by lenovo on 2017/7/14.
 */
@Service
public class WxReceiveMessageServiceImpl implements WxReceiveMessageService {

    @Autowired
    private WxReceiveMessageDao wxReceiveMessageDao;

    private static Logger logger = Logger.getLogger(WxReceiveMessageService.class);
    /**
     * 录入收货信息数据
     * @param wxReceiveMessageBean
     * @return
     */
    public boolean insertReceiveMessage(WxReceiveMessageBean wxReceiveMessageBean) {
        return wxReceiveMessageDao.insertReceiveMessage((WxReceiveMessage) ObjectUtil.transfer(wxReceiveMessageBean, WxReceiveMessage.class));
    }

    public CommonResult insertReceive(WxReceiveMessage record) {
        CommonResult result = new CommonResult();
        try {
            if(wxReceiveMessageDao.insertReceive(record)){
                result.setIsSuccess(true);
                result.setResultMsg("添加成功");
            }else {
                result.setIsSuccess(false);
                result.setResultMsg("添加失败");
            }
        }catch (Exception e){

            logger.error("添加收货信息异常", e);
        }
        return result;
    }

    public List<Map<String, Object>> selectReceiveBydetailId(Map<String, Object> map) {
        List<Map<String, Object>> ReceiveList = new ArrayList<Map<String, Object>>();
        try {
            ReceiveList = wxReceiveMessageDao.selectReceiveBydetailId(map);
        }catch (Exception e){
            logger.error("查询收货信息异常", e);
        }
        return ReceiveList;
    }
}
